<template>
    <div>
      <div class="bg-white grid-content">
        <div style="overflow: hidden; padding-bottom:8px;">
          <div class="mytitle"><svg-icon icon-class="yjbb" class="myIcon" />公司日产油10日变化曲线图</div>
        </div>
        <!-- 表格 -->
        <el-table :data="tableData" :header-cell-style="{background:'#F5F7FA',color:'#909399'}" border stripe >
          <el-table-column align="center" type="index" label="序号" :index="indexMethod" width="60">
          </el-table-column>
          <el-table-column align="center" prop="jid" label="井号">
          </el-table-column>
          <el-table-column align="center" prop="rq" label="日期">
          </el-table-column>
          <el-table-column align="center" prop="rcyl" label="日产油量">
          </el-table-column>
          <el-table-column align="center" prop="rcyl" label="日产液量">
          </el-table-column>
          <el-table-column align="center" prop="hsl" label="含水">
          </el-table-column>
          <el-table-column align="center" prop="rcsl" label="产水量">
          </el-table-column>
          <el-table-column align="center" prop="rcql" label="日产气量">
          </el-table-column>
          <el-table-column align="center" prop="cylLj" label="累计产油量">
          </el-table-column>
          <el-table-column align="center" prop="cylLj1" label="累计产液量">
          </el-table-column>
          <el-table-column align="center" prop="cslLj" label="累计产水量">
          </el-table-column>
          <el-table-column align="center" prop="cqlLj" label="累计产气量">
          </el-table-column>
          <el-table-column align="center" prop="wjmdcl" label="微机末端产量">
          </el-table-column>
          <el-table-column align="center" prop="pullingOil" label="拉油">
          </el-table-column>
          <el-table-column align="center" prop="bailing" label="提捞">
          </el-table-column>
          <el-table-column align="center" prop="landingOil" label="落地油">
          </el-table-column>
          <el-table-column align="center" prop="verifyProductionVolume" label="核实产量">
          </el-table-column>

          <el-table-column align="center" prop="bz" label="备注">
          </el-table-column>

        </el-table>
        <!-- 分页器 -->
        <el-pagination align='right'
                       background
                       @size-change="handleSizeChange"
                       @current-change="handleCurrentChange"
                       :current-page="pageNo"
                       :page-sizes="[5,10, 20, 30, 40, 50]"
                       :page-size="pageSize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="total">
        </el-pagination>
      </div>
      <div>
        <el-form :inline="true" class="demo-form-inline">
          <el-form-item label="开始日期:">
            <el-date-picker
              v-model="searchDate"
              type="date"
              align="right"
              unlink-panels
              value-format="yyyy-MM-dd"
              :picker-options="pickerOptions"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-select v-model="ziduanName" placeholder="请选择查询字段" filterable>
              <el-option label="日产液量" value="日产液量"></el-option>
              <el-option label="日产油量" value="日产油量"></el-option>
              <el-option label="日产水量" value="日产水量"></el-option>
              <el-option label="日产气量" value="日产气量"></el-option>
              <el-option label="含水率" value="含水率"></el-option>
              <el-option label="自用水量" value="自用水量"></el-option>
              <el-option label="自用气量" value="自用气量"></el-option>
              <el-option label="累计产油量" value="累计产油量"></el-option>
              <el-option label="累计产液量" value="累计产液量"></el-option>
              <el-option label="累计产水量" value="累计产水量"></el-option>
              <el-option label="累计产气量" value="累计产气量"></el-option>
              <el-option label="微机末端产量" value="微机末端产量"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="formSearch()">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div id="echarts"></div>
    </div>
</template>

  <script>
  import axios from "axios";
  import { getToken } from "@/utils/auth";
  import jianjcsjApi from '@/api/jcsj/jcsy/jianjcsj';
  import jlpzjApi from '@/api/jcsj/scgl/jlj/jlpzjscsj';
  import * as echarts from 'echarts';
  import moment from "moment";
  import yqjrscApi from "@/api/jcsj/scgl/jsj/yqjrsc";

  export default {
    data() {
      return {
        ziduanName:'日产液量',
        tableData: [],
        tuData:[],
        searchDate:'',
        //时间快捷选择
        pickerOptions: {
          // disabledDate(time) {
          //   return time.getTime() > Date.now();
          // },
          shortcuts: [
            {
              text: "今天",
              onClick(picker) {
                picker.$emit("pick", new Date());
              },
            },
            {
              text: "昨天",
              onClick(picker) {
                const date = new Date();
                date.setTime(date.getTime() - 3600 * 1000 * 24);
                picker.$emit("pick", date);
              },
            },
            {
              text: "一周前",
              onClick(picker) {
                const date = new Date();
                date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                picker.$emit("pick", date);
              },
            },
          ],
        },
      }
    },
    created(){
      var date=moment().format("YYYY-MM-DD")
      this.$data.leve = sessionStorage.getItem("userLeve");
      this.searchQx(date,"日产液量");
      this.search();
    },
    mounted(){


    },
    methods: {
      /*** 当每页数量发生变化时触发该事件 */
      handleSizeChange(size) {
        console.log(size);
        this.pageSize = size;
        //将每页显示的数量交给成员变量
        this.search(this.pageNo, size);
      },
      /*** 当页码发生变化时触发该事件 */
      handleCurrentChange(page) {
        console.log(page);
        this.pageNo = page;
        //调用查询方法
        this.search(page, this.pageSize);
      },
      async search() {
        // this.pageNo = pageNo; //当前页码
        // this.pageSize = pageSize; //每页显示数量
        //发送查询请求
        let res = await yqjrscApi.getList({pageNo:this.pageNo,pageSize:this.pageSize});
        //判断是否成功
        if(res.success){
          console.log('1',res.data);
          //赋值
          this.tableData = res.data.records;
          //总数量
          this.total = res.data.total;
        }
      },
      /**
       * 查询列表
       */
      async searchQx(rq,zdName) {
        // this.pageNo = pageNo; //当前页码
        // this.pageSize = pageSize; //每页显示数量
        //发送查询请求
        let res = await jlpzjApi.getTenList({startDate:rq,zdName:zdName});
        //判断是否成功
        if(res.success){
          //赋值
          this.tuData = res.data;
          var chartDom = document.getElementById('echarts');
          var myChart = echarts.init(chartDom);
          var option;
          var allDate=[]
          var yData=[]
          for(var i=0;i<this.tuData.length;i++){
            allDate.push(this.tuData[i].rq)
            yData.push(this.tuData[i].cl)
          }
          option = {
            title: {
              text: '曲线图'
            },
            xAxis: {
              type: 'category',
              data: allDate
            },
            yAxis: {
              type: 'value',
            },
            series: [
              {
                data: yData,
                type: 'line'
              }
            ]
          };

          option && myChart.setOption(option);
        }
      },
      formSearch() {
        this.searchQx(this.searchDate,this.ziduanName);
      },
    }
  }
  </script>

  <style lang="scss" scoped>
  // 标题
  .mytitle {
    font-size: large;
    padding-left: 10px;
    margin-bottom: 16px;
    float: left;
  }

  //按钮组
  .myButtons {
    float: right
  }

  //格子的样式
  .bg-white {
    background: #ffffff;
  }

  .grid-content {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
  }

  .calendar ::v-deep .el-button-group::before {
    display: none;
  }

  .calendar ::v-deep .el-button-group::after {
    display: none;
  }

  // 分割线样式
  .el-divider--horizontal {
    display: block;
    height: 2px;
    width: 100%;
    margin: 24px 0;
  }

  // 表单各项的样式
  .el-form-item {
    margin: 15px 10px 15px 10px;
  }

  //表单禁用字体样式
  .el-input.is-disabled ::v-deep .el-input__inner {
      color: #606266;
    }
  //对话框宽度
  // .customWidth{
  //         width:80%;
  //     }
  ::v-deep .saveAsDialog {
    width: 50% !important;
  }

  ::v-deep .el-table .cell{overflow: unset}
  //日期选择框宽度
  .el-date-editor.el-input, .el-date-editor.el-input__inner { width: 200px; }

  .el-input {
    width: 200px;
  }

  .tagstyle{
    cursor: pointer;
  }
  #echarts{
    width: 100%;
    height: 500px;
  }
  </style>
